﻿// array.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include<algorithm>

using namespace std;

vector<int> solution(string &R, vector<int>& V)
{
	vector<int> returnNum = {0, 0};
	int maxA = 0;
	int maxB = 0;
	int j = 0;
	for (int i = 0; i < R.size(); i++)
	{
		j = R[i] - 'A';
		if (j == 1)
		{
			returnNum[0] = returnNum[0] + V[i];
			returnNum[1] = returnNum[1] - V[i];
			if (returnNum[0] > maxA)
			{
				maxA = returnNum[0];
			}
		}
		if (j == 0)
		{
			returnNum[1] = returnNum[1] + V[i];
			returnNum[0] = returnNum[0] - V[i];
			if (returnNum[1] > maxB)
			{
				maxB = returnNum[1];
			}
		}	
	}
	returnNum[0] = maxA;
	returnNum[1] = maxB;
	return returnNum;
}

int main()
{
	vector<int> V = { 10, 5, 10, 15 };
	//vector<int> V = { 100 };
	//string R = "B";
	//vector<int> result = {0, 0};
	string R = "ABAB";
	vector<int> result;
	result = solution(R, V);
	for (int i = 0; i < result.size(); i++)
		cout << result[i] << endl;
	//cout << num1 << endl;
	return 0;

    //std::cout << "Hello World!\n";
}

